<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
	<th:block th:include="include :: header('订单管理')" />
</head>
<body class="white-bg">
	<div class="wrapper wrapper-content animated fadeInRight ibox-content">
		<form id="form-order-add" class="form-horizontal">
			<h4 class="form-header h4">基本信息</h4>
			<div class="row">
				<div class="col-sm-6">
					<div class="form-group">
						<label class="col-sm-4 control-label"><span style="color: red; ">*</span>订单名称：</label>
						<div class="col-sm-8">
							<input id="orderName" placeholder="请输入订单名称" class="form-control" type="text" required>
						</div>
					</div>
				</div>
				<div class="col-sm-6">
					<div class="form-group">
						<label class="col-sm-4 control-label"><span style="color: red; ">*</span>订单编号：</label>
						<div class="col-sm-8">
							<input id="orderNumber" placeholder="请输入订单名编号" class="form-control" type="text" required>
						</div>
					</div>
				</div>
			</div>
			<div class="row">
				<div class="col-sm-6">
					<div class="form-group">
						<label class="col-sm-4 control-label"><span style="color: red; ">*</span>订货时间：</label>
						<div class="col-sm-8">
							<input type="text" class="form-control time-input" data-type="datetime" id="orderTime" placeholder="请输入订货时间"  required/>
						</div>
					</div>
				</div>
				<div class="col-sm-6">
					<div class="form-group">
						<label class="col-sm-4 control-label"><span style="color: red; ">*</span>发货时间：</label>
						<div class="col-sm-8">
							<input type="text" class="form-control time-input" data-type="datetime" id="sendTime" placeholder="请输入发货时间"  required/>
						</div>
					</div>
				</div>
			</div>
			<div class="row">
				<div class="col-sm-6">
					<div class="form-group">
						<label class="col-sm-4 control-label">技术要求：</label>
						<div class="col-sm-8">
							<input id="skillRequire" placeholder="请输入技术要求" class="form-control" type="text">
						</div>
					</div>
				</div>
				<div class="col-sm-6">
					<div class="form-group">
						<label class="col-sm-4 control-label">材质：</label>
						<div class="col-sm-8">
							<input id="material" placeholder="请输入材质" class="form-control" type="text">
						</div>
					</div>
				</div>
			</div>
			<div class="row">
				<div class="col-sm-6">
					<div class="form-group">
						<label class="col-sm-4 control-label">尺寸：</label>
						<div class="col-sm-8">
							<input id="measure" placeholder="请输入尺寸" class="form-control" type="text">
						</div>
					</div>
				</div>
				<div class="col-sm-6">
					<div class="form-group">
						<label class="col-sm-4 control-label">包装：</label>
						<div class="col-sm-8">
							<input id="pack" placeholder="请输入包装" class="form-control" type="text" required>
						</div>
					</div>
				</div>
			</div>
			<div class="row" style="display: none;">
				<input id="orderType" value="1">
				<input id="orderStatus" value="1">
				<input id="uniCode" value="">
			</div>
			<h4 class="form-header h4">订单产品</h4>
			<div class="row">
				<div class="col-sm-6">
					<div class="form-group">
						<label class="col-sm-4 control-label">10kv开关：</label>
						<div class="col-sm-8">
							<input id="switch10" placeholder="请输入数量" class="form-control" type="number">
						</div>
					</div>
				</div>
				<div class="col-sm-6">
					<div class="form-group">
						<label class="col-sm-4 control-label">0.4kv开关：</label>
						<div class="col-sm-8">
							<input id="switch04" placeholder="请输入数量" class="form-control" type="number">
						</div>
					</div>
				</div>
			</div>
			<div class="row">
				<div class="col-sm-6">
					<div class="form-group">
						<label class="col-sm-4 control-label">110kv开关：</label>
						<div class="col-sm-8">
							<input id="switch110" placeholder="请输入数量" class="form-control" type="number">
						</div>
					</div>
				</div>
				<div class="col-sm-6">
					<div class="form-group">
						<label class="col-sm-4 control-label">35kv开关：</label>
						<div class="col-sm-8">
							<input id="switch35" placeholder="请输入数量" class="form-control" type="number">
						</div>
					</div>
				</div>
			</div>
			<div class="row">
				<div class="col-sm-6">
					<div class="form-group">
						<label class="col-sm-4 control-label">10kv刀闸：</label>
						<div class="col-sm-8">
							<input id="gate10" placeholder="请输入数量" class="form-control" type="number">
						</div>
					</div>
				</div>
				<div class="col-sm-6">
					<div class="form-group">
						<label class="col-sm-4 control-label">0.4kv刀闸：</label>
						<div class="col-sm-8">
							<input id="gate04" placeholder="请输入数量" class="form-control" type="number">
						</div>
					</div>
				</div>
			</div>
			<div class="row">
				<div class="col-sm-6">
					<div class="form-group">
						<label class="col-sm-4 control-label">110kv刀闸：</label>
						<div class="col-sm-8">
							<input id="gate110" placeholder="请输入数量" class="form-control" type="number">
						</div>
					</div>
				</div>
				<div class="col-sm-6">
					<div class="form-group">
						<label class="col-sm-4 control-label">35kv刀闸：</label>
						<div class="col-sm-8">
							<input id="gate35" placeholder="请输入数量" class="form-control" type="number">
						</div>
					</div>
				</div>
			</div>
			<div class="row">
				<div class="col-sm-6">
					<div class="form-group">
						<label class="col-sm-4 control-label">地刀：</label>
						<div class="col-sm-8">
							<input id="ground" placeholder="请输入数量" class="form-control" type="number">
						</div>
					</div>
				</div>
				<div class="col-sm-6">
					<div class="form-group">
						<label class="col-sm-4 control-label">手车双：</label>
						<div class="col-sm-8">
							<input id="doubleHandCar" placeholder="请输入数量" class="form-control" type="number">
						</div>
					</div>
				</div>
			</div>
			<div class="row">
				<div class="col-sm-6">
					<div class="form-group">
						<label class="col-sm-4 control-label">手车单：</label>
						<div class="col-sm-8">
							<input id="signleHandCar" placeholder="请输入数量" class="form-control" type="number">
						</div>
					</div>
				</div>
				<div class="col-sm-6">
					<div class="form-group">
						<label class="col-sm-4 control-label">电源12v1a：</label>
						<div class="col-sm-8">
							<input id="power121" placeholder="请输入数量" class="form-control" type="number">
						</div>
					</div>
				</div>
			</div>
			<div class="row">
				<div class="col-sm-6">
					<div class="form-group">
						<label class="col-sm-4 control-label">电源12v2a：</label>
						<div class="col-sm-8">
							<input id="power122" placeholder="请输入数量" class="form-control" type="number">
						</div>
					</div>
				</div>
				<div class="col-sm-6">
					<div class="form-group">
						<label class="col-sm-4 control-label">电源12v3a：</label>
						<div class="col-sm-8">
							<input id="power123" placeholder="请输入数量" class="form-control" type="number">
						</div>
					</div>
				</div>
			</div>
			<div class="row">
				<div class="col-sm-6">
					<div class="form-group">
						<label class="col-sm-4 control-label">电源12v4a：</label>
						<div class="col-sm-8">
							<input id="power124" placeholder="请输入数量" class="form-control" type="number">
						</div>
					</div>
				</div>
				<div class="col-sm-6">
					<div class="form-group">
						<label class="col-sm-4 control-label">电源12v5a：</label>
						<div class="col-sm-8">
							<input id="power125" placeholder="请输入数量" class="form-control" type="number">
						</div>
					</div>
				</div>
			</div>
			<div class="row">
				<div class="col-sm-6">
					<div class="form-group">
						<label class="col-sm-4 control-label">电源12v10a：</label>
						<div class="col-sm-8">
							<input id="power1210" placeholder="请输入数量" class="form-control" type="number">
						</div>
					</div>
				</div>
				<div class="col-sm-6">
					<div class="form-group">
						<label class="col-sm-4 control-label">电源12v29a：</label>
						<div class="col-sm-8">
							<input id="power1229" placeholder="请输入数量" class="form-control" type="number">
						</div>
					</div>
				</div>
			</div>
			<div class="row">
				<div class="col-sm-6">
					<div class="form-group">
						<label class="col-sm-4 control-label">19位：</label>
						<div class="col-sm-8">
							<input id="byte19" placeholder="请输入数量" class="form-control" type="number">
						</div>
					</div>
				</div>
				<div class="col-sm-6">
					<div class="form-group">
						<label class="col-sm-4 control-label">29位：</label>
						<div class="col-sm-8">
							<input id="byte29" placeholder="请输入数量" class="form-control" type="number">
						</div>
					</div>
				</div>
			</div>
		</form>
	</div>
	<th:block th:include="include :: footer" />
	 <script>
        var prefix = ctx + "order";


		$("#uniCode").val("OC"+uuid(8, 10));
        
        function submitHandler() {
	        if ($.validate.form()) {
				var obj = JSON.stringify({
					orderTimeStr: $("#orderTime").val(),
					sendTimeStr: $("#sendTime").val(),
					order: {
						orderNumber: $("#orderNumber").val(),
						orderName: $("#orderName").val(),
						skillRequire: $("#skillRequire").val(),
						material: $("#material").val(),
						measure: $("#measure").val(),
						pack: $("#pack").val(),
						orderType: $("#orderType").val(),
						orderStatus: $("#orderStatus").val(),
						uniCode: $("#uniCode").val()
					},
					orderProduct: {
						switch10: $("#switch10").val(),
						switch04: $("#switch04").val(),
						switch110: $("#switch110").val(),
						switch35: $("#switch35").val(),
						gate10: $("#gate10").val(),
						gate04: $("#gate04").val(),
						gate110: $("#gate110").val(),
						gate35: $("#gate35").val(),
						ground: $("#ground").val(),
						doubleHandCar: $("#doubleHandCar").val(),
						signleHandCar: $("#signleHandCar").val(),
						power121: $("#power121").val(),
						power122: $("#power122").val(),
						power123: $("#power123").val(),
						power124: $("#power124").val(),
						power125: $("#power125").val(),
						power1210: $("#power1210").val(),
						power1229: $("#power1229").val(),
						byte19: $("#byte19").val(),
						byte29: $("#byte29").val()
					}
				})
				var config = {
					url: prefix+'/add',
					type: "POST",
					dataType: "json",
					contentType: 'application/json;charset=UTF-8',
					data: obj,
					beforeSend: function () {
						$.modal.loading("正在处理中，请稍后...");
					},
					success: function(result) {
						if(result.code == 0){
							$.operate.successCallback(result);
						}
					}
				};
				$.ajax(config)
	        }
	    }

        $(function() {

        });

		function uuid(len, radix) {
			var chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.split('');
			var uuid = [], i;
			radix = radix || chars.length;

			if (len) {
				// Compact form
				for (i = 0; i < len; i++) uuid[i] = chars[0 | Math.random()*radix];
			} else {
				// rfc4122, version 4 form
				var r;

				// rfc4122 requires these characters
				uuid[8] = uuid[13] = uuid[18] = uuid[23] = '-';
				uuid[14] = '4';

				// Fill in random data.  At i==19 set the high bits of clock sequence as
				// per rfc4122, sec. 4.1.5
				for (i = 0; i < 36; i++) {
					if (!uuid[i]) {
						r = 0 | Math.random()*16;
						uuid[i] = chars[(i == 19) ? (r & 0x3) | 0x8 : r];
					}
				}
			}

			return uuid.join('');
		}

    </script>
</body>
</html>
